﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Net.Mail;
using System.Timers;
using System.Threading;
using System.Configuration;
using System.Collections.Specialized;
using System.Security.Cryptography;
using WebKpiPage.Data.Common;
using Model;
using Model.GongDanMgr;
namespace WebKpiPage.Data.GongdanMgr
{
    public static  class GongdanMgrCls
    {
       
        private static System.Threading.Timer timer = null;   
        /// <summary>
        /// 添加WF工单记录
        /// </summary>
        /// <returns></returns>
        public static int AddWFGongDanRecord(WFGongdanRecord record,string trantype)
        {
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                return -1;
            }
            try
            {	
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_编辑_WF_工单记录表]";
                int count = 13;
                SqlParameter[] sp = new SqlParameter[count];
                sp[--count] = new SqlParameter("@Trantype", trantype);
                sp[--count] = new SqlParameter("@ID", record.ID);
                sp[--count] = new SqlParameter("@FK_工单表_ID", record.FK_工单表_ID);
                sp[--count] = new SqlParameter("@WorkflowInstanceId", record.WorkflowInstanceId);
                sp[--count] = new SqlParameter("@ActivityId", record.ActivityId);
                sp[--count] = new SqlParameter("@ActivityDescription", record.ActivityDescription);
                sp[--count] = new SqlParameter("@FK_SenderUser_ID", record.FK_SenderUser_ID);
                  sp[--count] = new SqlParameter("@FK_RecUser_ID", record.FK_RecUser_ID);
                sp[--count] = new SqlParameter("@SignRemark", record.SignRemark);
                sp[--count] = new SqlParameter("@记录日期", record.J记录日期);
                sp[--count] = new SqlParameter("@WorkflowId", record.WorkflowId);
                sp[--count] = new SqlParameter("@FK_WF_工单状态ID", record.FK_WF_工单状态ID);
                sp[--count] = new SqlParameter("@FK_Type_ID", record.FK_Type_ID);
               int rtn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, commandText, sp);
               return rtn;
            }
            catch (Exception)
            {
                return -1;
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }

        /// <summary>
        /// 添加工单处理记录
        /// </summary>
        /// <returns></returns>
        public static int AddGongDanRecord(GongDanDelRecord record)
        {
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogInfo("AddGongDanRecord  conn == null || conn.State != System.Data.ConnectionState.Open");
                return -1;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_添加工单处理记录]";
                int count = 10;
                SqlParameter[] sp = new SqlParameter[count];
                sp[--count] = new SqlParameter("@ID", record.ID);
                sp[--count] = new SqlParameter("@FK_SenderUser_ID", record.FK_SenderUser_ID);
                  sp[--count] = new SqlParameter("@FK_RecUser_ID", record.FK_RecUser_ID);
                sp[--count] = new SqlParameter("@WF_Instance_ID", record.WF_Instance_ID);
                sp[--count] = new SqlParameter("@主题", record.主题);
                sp[--count] = new SqlParameter("@接收日期", record.J接收日期);
                sp[--count] = new SqlParameter("@处理日期", record.C处理日期);
                sp[--count] = new SqlParameter("@FK_WF_工单记录表_ID", record.FK_WF_工单记录表_ID);
                sp[--count] = new SqlParameter("@是否已读", record.S是否已读);
                sp[--count] = new SqlParameter("@是否已处理", record.S是否已处理);
                int rtn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, commandText, sp);
                return rtn;
            }
            catch (Exception e)
            {
                LogSystem.LogError("AddGongDanRecord", e);
                return -1;
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }

        /// <summary>
        /// 生成告警工单或更新工单
        /// </summary>
        /// <returns></returns>
        public static DataSet  MakeXingNengRecords()
        {
            string currentDate = "2012-10-07";//DateTime.Now.ToString("yyyy-MM-dd"); //
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogError("MakeXingNengRecords, conn == null || conn.State != System.Data.ConnectionState.Open");
                return null;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_生成性能告警工单]";
                SqlParameter[] sp = new SqlParameter[1];
                sp[0] = new SqlParameter("@日期", currentDate);
                DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, commandText, sp);
    
                return ds;
               
            }
            catch (Exception e)
            {
                LogSystem.LogError("MakeXingNengRecords", e);
                return null;
             
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
        /// <summary>
        /// 根据片区名查询需要指派的组员
        /// </summary>
        /// <param name="pianquName"></param>
        /// <returns></returns>
        public static Guid  GetMemberIDByPianquName(string pianquName)
        {
           
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogError("MakeXingNengRecords, conn == null || conn.State != System.Data.ConnectionState.Open");
                return Guid.Empty;;
            }
            try
            {
                Guid memberID = Guid.Empty;
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_查询_根据片区名查询需要指派的组员]";
                SqlParameter[] sp = new SqlParameter[2];
                sp[0] = new SqlParameter("@片区名", pianquName);
               
                sp[1] = new SqlParameter("@FK_责任人_ID", memberID);
                sp[1].Direction = ParameterDirection.Output;
                SqlParameterCollection parameterCollection = null;
                SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, commandText, out parameterCollection, sp);

                memberID =new Guid(parameterCollection["@FK_责任人_ID"].Value.ToString());
                return memberID;
               
            }
            catch (Exception e)
            {
                LogSystem.LogError("MakeXingNengRecords", e);
                return Guid.Empty; ;
             
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
       
        /// <summary>
        /// 更新工单记录表
        /// </summary>
        /// <param name="proj"></param>
        /// <returns></returns>
        public static bool UpdateGongdanRecord(GongDanProj proj)
        {
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogError("UpdateGongdanRecord, conn == null || conn.State != System.Data.ConnectionState.Open");
                return false;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_修改工单]";
                int count = 17;
                SqlParameter[] sp = new SqlParameter[count];
                sp[--count] = new SqlParameter("@id", proj.ID);
                sp[--count] = new SqlParameter("@FK_WF_工单当前状态", proj.FK_WF_工单当前状态);
               // sp[--count] = new SqlParameter("@流水号", proj.L流水号);
              //  sp[--count] = new SqlParameter("@工单名称", proj.G工单名称);
              //  DateTime? C产生时间 = proj.C产生时间;
              //  sp[--count] = new SqlParameter("@产生时间 ", C产生时间);
              //  sp[--count] = new SqlParameter("@告警ID", proj.G告警ID);
              //  sp[--count] = new SqlParameter("@告警名称", proj.G告警名称);
              //  sp[--count] = new SqlParameter("@告警级别", proj.G告警级别);
              // sp[--count] = new SqlParameter("@告警对象", proj.G告警对象);
                //sp[--count] = new SqlParameter("@网元名称", proj.W网元名称);
                //sp[--count] = new SqlParameter("@小区ID", proj.X小区ID);
               // sp[--count] = new SqlParameter("@小区名称", proj.X小区名称);
               // sp[--count] = new SqlParameter("@BSC名称", proj.BSC名称);
              //  sp[--count] = new SqlParameter("@地市名称", proj.D地市名称);
              //  sp[--count] = new SqlParameter("@区镇名称", proj.Q区镇名称);
              //  sp[--count] = new SqlParameter("@片区名称", proj.P片区名称);
               // sp[--count] = new SqlParameter("@所属网格", proj.S所属网格);
              //  sp[--count] = new SqlParameter("@所属道路", proj.S所属道路);
               // DateTime? Z最早劣化时段 = proj.Z最早劣化时段;
              //  DateTime? Z最新劣化时段 = proj.Z最新劣化时段;
               // sp[--count] = new SqlParameter("@最早劣化时段 ", Z最早劣化时段);
              //  sp[--count] = new SqlParameter("@最新劣化时段", Z最新劣化时段);
              //  sp[--count] = new SqlParameter("@总劣化时段数", proj.Z总劣化时段数);
              //  sp[--count] = new SqlParameter("@劣化时段单位", proj.L劣化时段单位);
               // sp[--count] = new SqlParameter("@BSC_华为", proj.BSC_华为);
                sp[--count] = new SqlParameter("@FK_User_责任人", proj.FK_User_责任人);
                sp[--count] = new SqlParameter("@原因定位", proj.Y原因定位);
                sp[--count] = new SqlParameter("@详细原因", proj.X详细原因);
                sp[--count] = new SqlParameter("@优化记录", proj.Y优化记录);
                sp[--count] = new SqlParameter("@附件", proj.F附件);
                sp[--count] = new SqlParameter("@备注", proj.B备注);
                sp[--count] = new SqlParameter("@FK_User_最新处理人",proj.FK_User_最新处理人);
                sp[--count] = new SqlParameter("@最新处理时间", proj.Z最新处理时间);
                sp[--count] = new SqlParameter("@一级督办批示", proj.Y一级督办批示);
                sp[--count] = new SqlParameter("@一级督办人", proj.Y一级督办人);

                DateTime? Y一级督办时间 = proj.Y一级督办时间;
                DateTime? E二级督办时间 = proj.E二级督办时间;
               // DateTime? H恢复时间 = proj.H恢复时间;
                sp[--count] = new SqlParameter("@一级督办时间 ", Y一级督办时间);
                sp[--count] = new SqlParameter("@二级督办批示", proj.E二级督办批示);
                sp[--count] = new SqlParameter("@二级督办人", proj.E二级督办人);
                sp[--count] = new SqlParameter("@二级督办时间", E二级督办时间);
                sp[--count] = new SqlParameter("@问题描述", proj.ProblemDesc);
              //  sp[--count] = new SqlParameter("@恢复时间", H恢复时间);
                //sp[--count] = new SqlParameter("@恢复类型", proj.H恢复类型);
               // sp[--count] = new SqlParameter("@添加时间 ", proj.T添加时间);
                SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, commandText, sp);
                return true;

            }
            catch (Exception e)
            {
                LogSystem.LogError("MakeXingNengRecords", e);
                return false;
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
        public static DataSet GetDongdanRecordByUserId(string userID,int status)
        {
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                return null;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_查询_根据用户ID获取工单]";
                SqlParameter[] sp = new SqlParameter[2];
                sp[0] = new SqlParameter("@userID", new Guid(userID));
                sp[1] = new SqlParameter("@是否待办", status);
                
                DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, commandText, sp);

              
                return ds;
            }
            catch (Exception e)
            {
                LogSystem.LogError("GetDongdanRecordByUserId:"+userID, e);
                return null;
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
        /// <summary>
        /// 获取评估状态的工单，决定升级or关闭 @时间间隔 int=7  ,@状态 
        /// </summary>
        /// <param name="timeInterview"></param>
        /// <param name="status">8:升级到网优主管  6：升级到网优主任</param>
        /// <returns></returns>
        public static DataSet GetPingGuStatsGongdan(int timeInterview,int status)
        {
         
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogError("GetPingGuStatsGongdan, conn == null || conn.State != System.Data.ConnectionState.Open");
                return null;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_查询_工单是否升级]";
                SqlParameter[] sp = new SqlParameter[2];
                sp[0] = new SqlParameter("@时间间隔", timeInterview);
                sp[1] = new SqlParameter("@状态", status);
                DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, commandText, sp);
                return ds;
               
            }
            catch (Exception e)
            {
                LogSystem.LogError("GetPingGuStatsGongdan", e);
                return null;
             
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
        public static bool UpdateGongdanDelwith(Guid userId,Guid instanceId)
        {
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogError("GetUnUpGongdan, conn == null || conn.State != System.Data.ConnectionState.Open");
                return false;
            }
            try
            {
                string commandText = "update MTNOH_GZ_APP.[dbo].MT_工单处理记录表 set 是否已处理=1 ,是否已读=1 where WF_Instance_ID="+instanceId+
                    " and FK_RecUser_ID="+userId;

                int count = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandText);
                if (count > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }

            }
            catch (Exception e)
            {
                LogSystem.LogError("GetUnUpGongdan", e);
                return false;

            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
        /// <summary>
        /// 根据处理记录ID 更新处理记录表
        /// </summary>
        /// <param name="delwithId"></param>
        /// <returns></returns>
        public static bool UpdateGongdanDelwith(Guid delwithId, Guid instanseID,
            string remark, Guid sendUserId,int type)
        {
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogError("GetUnUpGongdan, conn == null || conn.State != System.Data.ConnectionState.Open");
                return false;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_编辑_工单处理记录]";
                SqlParameter[] sp = new SqlParameter[5];
                sp[0] = new SqlParameter("@ID", delwithId);
                sp[1] = new SqlParameter("@instanseID", instanseID);
                sp[2] = new SqlParameter("@remark", remark);
                sp[3] = new SqlParameter("@sendUserId", sendUserId);
                sp[4] = new SqlParameter("@type", type);
                int count= SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, commandText, sp);
                return count > 0 ? true : false;
              
            }
            catch (Exception e)
            {
                LogSystem.LogError("GetUnUpGongdan", e);
                return false;

            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }

        public static int GongdanIsClose(Guid workflowInstanceId)
        {
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogError("GetUnUpGongdan, conn == null || conn.State != System.Data.ConnectionState.Open");
                return -1;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_查询_工单是否关闭]";
                int count = 1;
                SqlParameter[] sp = new SqlParameter[count];
                sp[--count] = new SqlParameter("@workflowInstanceId", workflowInstanceId);

              DataSet ds= SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, commandText, sp);
              if (ds!=null&&ds.Tables[0].Rows.Count>0)
              {
                  return 1;
              }
              else
              {
                  return 0;
              }

            }
            catch (Exception e)
            {
                LogSystem.LogError("GetUnUpGongdan", e);
                return -1;

            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
        public  static DataSet GetWfGonddanRecord(Guid id)
        {
            
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogError("MakeXingNengRecords, conn == null || conn.State != System.Data.ConnectionState.Open");
                return null;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_查询_WF_工单记录表]";
                SqlParameter[] sp = new SqlParameter[2];
                sp[0] = new SqlParameter("@Trantype", "ById");
                sp[1] = new SqlParameter("@ID", id);
                DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, commandText, sp);
                return ds;
               
            }
            catch (Exception e)
            {
                LogSystem.LogError("MakeXingNengRecords", e);
                return null;
             
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
        public static DataSet GetNextUser(Guid curentUserId)
        {
            
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogError("UpdateGongdanDelRecord, conn == null || conn.State != System.Data.ConnectionState.Open");
                return null;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_查询_流程的下一个用户]";
                SqlParameter[] sp = new SqlParameter[1];
                sp[0] = new SqlParameter("@userId", curentUserId);
                DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, commandText, sp);
                return ds;

            }
            catch (Exception e)
            {
                LogSystem.LogError("UpdateGongdanDelRecord", e);
                return null;

            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
        
        public static DataSet GetTimeOutGonddan(int interView,string activeId){
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogError("GetTimeOutGonddan, conn == null || conn.State != System.Data.ConnectionState.Open");
                return null;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_查询_超时未处理工单]";
                SqlParameter[] sp = new SqlParameter[1];
                sp[0] = new SqlParameter("@超时天数", interView);
                sp[1] = new SqlParameter("@状态", activeId);
                DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, commandText, sp);
                return ds;
            }
            catch (Exception e)
            {
                LogSystem.LogError("UpdateGongdanDelRecord", e);
                return null;
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
        /// <summary>
        /// 更新工单处理记录
        /// </summary>
        /// <param name="id"></param>
        /// <param name="userId">责任人</param>
        /// <param name="status"></param>
        /// <returns></returns>
        public static bool UpdateGongdanRecordWf(GongDanProj proj)
        {

            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogError("UpdateGongdanDelRecord, conn == null || conn.State != System.Data.ConnectionState.Open");
                return false;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_修改_工单记录表状态]";
                int count = 10;
                SqlParameter[] sp = new SqlParameter[count];
                sp[--count] = new SqlParameter("@status", (int)proj.FK_WF_工单当前状态);
                sp[--count] = new SqlParameter("@id", proj.ID);
                sp[--count] = new SqlParameter("@FK_User_责任人", proj.FK_User_责任人);
                sp[--count] = new SqlParameter("@原因定位", proj.Y原因定位);
                sp[--count] = new SqlParameter("@详细原因", proj.X详细原因);
                sp[--count] = new SqlParameter("@备注", proj.B备注);
                sp[--count] = new SqlParameter("@最新处理时间", DateTime.Now);
                sp[--count] = new SqlParameter("@优化记录", proj.Y优化记录);
                sp[--count] = new SqlParameter("@FK_User_最新处理人", proj.FK_User_最新处理人);
                sp[--count] = new SqlParameter("@问题描述", proj.ProblemDesc);

                int nums = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, commandText, sp);
                return true;

            }
            catch (Exception e)
            {
                LogSystem.LogError("UpdateGongdanDelRecord", e);
                return false;

            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }

        public static bool EditGongdanRequest(GongDanRequest gongdanRequest)
        {
            //

            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogError("UpdateGongdanDelRecord, conn == null || conn.State != System.Data.ConnectionState.Open");
                return false;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_编辑_工单申请延期表]";
                int count = 7;
                SqlParameter[] sp = new SqlParameter[count];
                sp[--count] = new SqlParameter("@FK_工单ID",gongdanRequest.GongdanID);
                sp[--count] = new SqlParameter("@延期天数", gongdanRequest.RequestDayNums);
                sp[--count] = new SqlParameter("@FK_申请人", gongdanRequest.RequestMan);
                sp[--count] = new SqlParameter("@申请时间", DateTime.Now);
                sp[--count] = new SqlParameter("@是否批准", gongdanRequest.IsAgree);
                sp[--count] = new SqlParameter("@批复时间", DateTime.Now);
                sp[--count] = new SqlParameter("@FK_批复人", gongdanRequest.AnswerMan);
                SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, commandText, sp);
                return true;

            }
            catch (Exception e)
            {
                LogSystem.LogError("UpdateGongdanDelRecord", e);
                return false;

            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
           
        }

        #region 任务查询
        public static DataSet GetAllTask(AllTaskParamItem param)
        {
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                LogSystem.LogInfo("AddGongDanRecord  conn == null || conn.State != System.Data.ConnectionState.Open");
                return null;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.dbo.mtsp_查询_任务信息列表";
                int count = 7;
                SqlParameter[] sp = new SqlParameter[count];
                sp[--count] = new SqlParameter("@orderType", param.orderType);
                sp[--count] = new SqlParameter("@beginTime", param.beginTime);
                sp[--count] = new SqlParameter("@endTime", param.endTime);
                sp[--count] = new SqlParameter("@cell", param.cell);
                sp[--count] = new SqlParameter("@problemPoint", param.problemPoint);
                sp[--count] = new SqlParameter("@page_size", param.pageSize);
                sp[--count] = new SqlParameter("@page_index", param.currentpage);
                DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, commandText, sp);
                if (ds != null && ds.Tables.Count > 0)
                {
                    return ds;
                }
                return null;
            }
            catch (Exception e)
            {
                LogSystem.LogError("GetAllTask", e);
                return null;
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
        #endregion
    }
}
